package com.judian.smart.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Environment;
import android.util.Log;

import java.io.File;

public class BootStartReceiver extends BroadcastReceiver {
    private static final String TAG = BootStartReceiver.class.getSimpleName();
    private static final String ACTION = "android.intent.action.BOOT_COMPLETED";


    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        assert action != null;
        if (action.equals(ACTION)) {
            //开机删除会播放的TTs音频文件
            new Thread(new Runnable() {
                @Override
                public void run() {
                    File file = new File(Environment.getExternalStorageDirectory().getPath() + "/msc/tts.wav");
                    if (file.exists()) {
                        boolean deleteResult = file.delete();   //此处解决开机TTs音频文件播报问题
                        Log.d(TAG, "onReceive: 删除TTs文件状态" + deleteResult);
                    }
                }
            }).start();
        }
    }
}
